package com.travelshare.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.travelshare.common.annotation.Log;
import com.travelshare.common.core.controller.BaseController;
import com.travelshare.common.core.domain.AjaxResult;
import com.travelshare.common.enums.BusinessType;
import com.travelshare.business.domain.InfoColumn;
import com.travelshare.business.service.IInfoColumnService;
import com.travelshare.common.utils.poi.ExcelUtil;

/**
 * 栏目信息Controller
 * 
 * @author travelshare
 * @date 2024-02-22
 */
@RestController
@RequestMapping("/business/infoColumn")
public class InfoColumnController extends BaseController
{
    @Autowired
    private IInfoColumnService infoColumnService;

    /**
     * 查询栏目信息列表
     */
    @PreAuthorize("@ss.hasPermi('business:infoColumn:list')")
    @GetMapping("/list")
    public AjaxResult list(InfoColumn infoColumn)
    {
        List<InfoColumn> list = infoColumnService.selectInfoColumnList(infoColumn);
        return success(list);
    }

    /**
     * 导出栏目信息列表
     */
    @PreAuthorize("@ss.hasPermi('business:infoColumn:export')")
    @Log(title = "栏目信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InfoColumn infoColumn)
    {
        List<InfoColumn> list = infoColumnService.selectInfoColumnList(infoColumn);
        ExcelUtil<InfoColumn> util = new ExcelUtil<InfoColumn>(InfoColumn.class);
        util.exportExcel(response, list, "栏目信息数据");
    }

    /**
     * 获取栏目信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:infoColumn:query')")
    @GetMapping(value = "/{columnId}")
    public AjaxResult getInfo(@PathVariable("columnId") Long columnId)
    {
        return success(infoColumnService.selectInfoColumnByColumnId(columnId));
    }

    /**
     * 新增栏目信息
     */
    @PreAuthorize("@ss.hasPermi('business:infoColumn:add')")
    @Log(title = "栏目信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InfoColumn infoColumn)
    {
    	infoColumn.setCreateBy(getUsername());
        return toAjax(infoColumnService.insertInfoColumn(infoColumn));
    }

    /**
     * 修改栏目信息
     */
    @PreAuthorize("@ss.hasPermi('business:infoColumn:edit')")
    @Log(title = "栏目信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InfoColumn infoColumn)
    {
    	infoColumn.setUpdateBy(getUsername());
        return toAjax(infoColumnService.updateInfoColumn(infoColumn));
    }

    /**
     * 删除栏目信息
     */
    @PreAuthorize("@ss.hasPermi('business:infoColumn:remove')")
    @Log(title = "栏目信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{columnIds}")
    public AjaxResult remove(@PathVariable Long[] columnIds)
    {
        return toAjax(infoColumnService.deleteInfoColumnByColumnIds(columnIds));
    }
}
